package com.evenmo.string;

import org.junit.Test;

/**
 * 比较hashCode
 */
public class CompareHashCode {
    @Test
    public void testHashCode(){
        String s1="hello";
        String s2="holle";
        String s3=new String("hello");
        System.out.println(s1 == s1);
        System.out.println("s1.hashcode="+s1.hashCode());
        System.out.println("s2.hashcde ="+s2.hashCode());
        System.out.println(s1.equals(s2));
        System.out.println(s1.hashCode() == s2.hashCode());
        System.out.println("s3.hashcode()="+ s3.hashCode());

        System.out.println(s1 == s3);
        System.out.println(s1.equals(s3));

        System.out.println("----------------");

        String str1 = "通话";
        String str2 = "重地";
        System.out.println();
        System. out. println(String. format("str1：%d | str2：%d",  str1. hashCode(),str2. hashCode()));
        System. out. println(str1. equals(str2));


    }
}
